{% extends 'TopxiaWebBundle::layout.html.twig' %}

{% set bodyClass = 'course-list-page bg-blank' %}
{% set siteNav = 'course/explore' %}
{% set script_controller = 'course/explore' %}

{% block keywords %}{% if categoryArray %}{{categoryArray.name}}{% if CategoryParent %}{{ ','}}{{ CategoryParent.name|default('') }}{% endif %}{% else %}{{ '全部' }}{% endif %}{% endblock %}
  {% block description %}{{ categoryArrayDescription|default('')|plain_text(100) }}{% endblock %}
    {% block title %}{{ categoryArray.name|default('全部') }} - {{setting('site.name')}}{% if setting('site.slogan') %}{{' - '}}{{setting('site.slogan')}}{% endif %}{% if not setting('copyright.owned') %} - Powered By EduSoho{% endif %}
    {% endblock %}

{% block top_content %}
  <div class="es-banner">
    <div class="container">
      <div class="title">
        <i class="es-icon es-icon-viewcomfy"></i>
        课程列表
      </div>
      {% if setting("classroom.enabled") %}
      <a class="btn btn-primary btn-lg more" href="{{path('classroom_explore')}}">
        查看{{ setting('classroom.name')|default('班级') }}
      </a>
      {% endif %}
    </div>
  </div>
{% endblock %}

{% block content %}
  {% set fliter = fliter|default('all') %}
  {% set orderBy = orderBy|default('latest')%}
  {{ render(controller('TopxiaWebBundle:Category:treeNav',{category:category|default(''), path:'course_explore',fliter:fliter,orderBy:orderBy})) }}
  <div class="course-filter" id="course-filter">
    <ul class="nav nav-pills hidden-xs" role="tablist">
      <li role="presentation" class="{% if (fliter == 'all') %}active {% endif %}"><a href="{{ path('course_explore',{category:category, fliter:'all',orderBy : orderBy}) }}">全部课程</a></li>
      <li role="presentation"class="{% if (fliter == 'free') %}active {% endif %}"><a href="{{ path('course_explore', {category:category, fliter:'free',orderBy: orderBy}) }}">免费课程</a></li>
      {% if setting("course.live_course_enabled") == 1 %}
      <li role="presentation"class="{% if (fliter == 'live') %}active {% endif %}"><a href="{{ path('course_explore', {category:category, fliter:'live',orderBy: orderBy}) }}">直播课程</a></li>
      {% endif %}
    </ul>
    <div class="btn-group visible-xs">
      <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">{{ dict_text('searchCourseType',fliter|default('all')) }} <span class="caret"></span></button>
      <ul class="dropdown-menu" role="menu">
        <li><a href="{{ path('course_explore',{category:category, fliter:'all',orderBy : orderBy|default('latest')}) }}" class="{% if (fliter == 'all') %}active {% endif %}">全部课程</a></li>
        <li><a href="{{ path('course_explore', {category:category, fliter:'free',orderBy: orderBy|default('latest')}) }}" class="{% if (fliter == 'free') %}active {% endif %}">免费课程</a></li>
        <li><a href="{{ path('course_explore', {category:category, fliter:'live',orderBy: orderBy|default('latest')}) }}" class="{% if (fliter == 'live') %}active {% endif %}">直播课程</a></li>
      </ul>
    </div>
    <div class="course-sort btn-group">
      <a href="{{ path('course_explore', {category:category, fliter:fliter,orderBy: 'latest'}) }}" class="btn btn-default {% if (orderBy == 'latest') %} active {% endif %}">
        最新
      </a>
      <a href="{{ path('course_explore', {category:category, fliter:fliter,orderBy: 'studentNum'}) }}" class="btn btn-default {% if (orderBy == 'studentNum') %} active {% endif %}">
        最热
      </a>
      <a href="{{ path('course_explore', {category:category, fliter:fliter,orderBy: 'recommendedSeq'}) }}" class="btn btn-default {% if (orderBy == 'recommendedSeq') %} active {% endif %}">
        推荐
      </a>
    </div>
  </div>
  <div class="course-list">
    <div class="row">
      {% if courses %}
        {% for course in courses %}
          <div class="col-lg-3 col-md-4 col-sm-6">
            {% include 'TopxiaWebBundle:Course:Widget/course-grid.html.twig' %}
          </div>
        {% endfor %}
      {% else %}
        <div class="empty">该分类下无课程</div>
      {% endif %}
    </div>
  </div>
  <nav class="text-center">
    {{ web_macro.paginator(paginator) }}
  </nav>
{% endblock %}